package com.hpin.mlxteacher.message;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.adapter.ClassifyAdapter;
import com.hpin.mlxteacher.base.BaseActivity;
import com.hpin.mlxteacher.pulltorefush.PullToRefreshListView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Aaron on 2015/7/21.
 */
public class ClassifyActivity extends BaseActivity {

    /**
     * 分类code
     */
    private static final int CLASSIFY_CODE = 1007;
    private PullToRefreshListView plv_classify;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_classify);

        initWidget();

    }

    private void initWidget() {

        ImageView tv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);
        TextView tv_right = (TextView) findViewById(R.id.tv_right);

        tv_title.setText(getResources().getString(R.string.message_classify));
        tv_right.setVisibility(View.INVISIBLE);

        tv_left.setOnClickListener(this);


        ListView lv_classify = (ListView) findViewById(R.id.lv_classify);

        List<String> str = new ArrayList<String>();
        str.add("消息");
        str.add("待办事件");
        str.add("通知");
        ClassifyAdapter classifyAdapter = new ClassifyAdapter(ClassifyActivity.this, str);

        lv_classify.setAdapter(classifyAdapter);

        lv_classify.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Intent data = new Intent();
                data.putExtra("classify", "消息");
                setResult(CLASSIFY_CODE, data);
                finish();
            }
        });

//        plv_classify = (PullToRefreshListView) findViewById(R.id.plv_classify);
//
//        plv_classify.setMode(PullToRefreshBase.Mode.BOTH);
//
//        plv_classify.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
//            @Override
//            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
//
////                ClassifyAdapter classifyAdapter = new ClassifyAdapter(ClassifyActivity.this);
//
////                ListView refreshableView = plv_classify.getRefreshableView();
////                refreshableView.setAdapter(classifyAdapter);
//
////                plv_classify.setAdapter(classifyAdapter);
//
//                LogUtil.e("TAG" , "Thread==>" + Thread.currentThread());
//
//                plv_classify.onRefreshComplete();
//
////                classifyAdapter.notifyDataSetChanged();
//
//            }
//
//            @Override
//            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
//                plv_classify.onRefreshComplete();
//            }
//        });



    }



    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {

            case R.id.iv_left :
            //返回
                finish();
                break;


        }
    }




}
